\documentclass{article}
\usepackage{fullpage}


% If your system does not have the AMS fonts version 2.0 installed, then
% remove the useAMS option.
%
% useAMS allows you to obtain upright Greek characters.
% e.g. \umu, \upi etc.  See the section on "Upright Greek characters" in
% this guide for further information.
%
% If you are using AMS 2.0 fonts, bold math letters/symbols are available
% at a larger range of sizes for NFSS release 1 and 2 (using \boldmath or
% preferably \bmath).
%
% The usenatbib command allows the use of Patrick Daly's natbib.sty for
% cross-referencing.
%
% If you wish to typeset the paper in Times font (if you do not have the
% PostScript Type 1 Computer Modern fonts you will need to do this to get
% smoother fonts in a PDF file) then uncomment the next line
% \usepackage{Times}

%%%%% AUTHORS - PLACE YOUR OWN MACROS HERE %%%%%


%% cosmology
%% ions / absorbers
\newcommand{\HI}{\hbox{{\sc H}{\sc i}} }
\newcommand{\NHI}{{N_{\rm HI}}}
\newcommand{\fNHI}{f(N_{\rm HI},X)}

\newcommand{\DXobs}{\Delta X^{\rm obs}}
\newcommand{\DXsim}{\Delta X^{\rm sim}}

\newcommand{\dXobs}{dX^{\rm obs}}
\newcommand{\dXsim}{dX^{\rm sim}}

\newcommand{\Ob}{\Omega_{\rm b} }
\newcommand{\Om}{\Omega_{\rm m} }
\newcommand{\OHI}{\Omega_{\rm HI} }
\newcommand{\OHH}{\Omega_{\rm H2} }
\newcommand{\Ol}{\Omega_{\Lambda} }
\newcommand{\Mpch}{h^{-1} \rm{\,Mpc} }

% codes / simulations
\newcommand{\OWLS}{{\small OWLS} }

% journals

\newcommand{\mnras}{MNRAS}
\newcommand{\apjl}{ApJL}
\newcommand{\apj}{ApJ}
\newcommand{\apjs}{ApJS}
\newcommand{\aap}{A\&A}
\newcommand{\araa}{ARA\&A}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\title{SPH Tricks}
\author{Gabriel Altay}
\begin{document}
\maketitle



\section{Rescaling Glass Distributions}
 
It is frequently useful to transform a uniform glass distribution to
some other distribution with a known density profile.  Here we will
derive some common transformations.  The idea is that the particles
have a constant mass and so the total mass before and after the
transition must be conserved. The original glass densities as a function
of the original particle positions will be denoted $\rho(\bf{r})$ and
the new densities as a function of the new particle positions will be
denoted $\rho^\prime(\bf{r^\prime})$.  Often, the glass density can be
taken as a constant $\rho_0$ (i.e. we can ignore fluctuations in the
glass density field). 


\subsection{Cartesian Power Law}

In this case, we write down the expression for the mass in a planar
slab and derive the scaling that will give us a power law 
$\rho^\prime(z^\prime) \propto z^{\prime -\alpha}$.   The new
density is only a function of the magnitude of the new z-coordinate
$z^\prime$. 

\begin{eqnarray}
\rho({\bf r}) dx \, dy \, dz &=&  
\rho^\prime(r^\prime) 
dx^{\prime} \, dy^{\prime} \, dz^{\prime}
\\  
\rho_0 dx \, dy \, dz &=&
\rho^\prime(z^\prime) 
dx^{\prime} \, dy^{\prime} \, dz^{\prime}
\\  
\rho^\prime(z^\prime) &=&
\rho_0 
\frac{dx}{dx^\prime}
\frac{dy}{dy^\prime}
\frac{dz}{dz^\prime}
\propto z^{\prime - \alpha}
\end{eqnarray}
where we have imposed the last proportionality as a requirement for
the new density field. 

\begin{eqnarray}
dx \, dy \, dz &\propto& z^{\prime - \alpha} 
dx^{\prime} \, dy^{\prime} \, dz^\prime 
\\
\int dx \, dy \, dz &\propto& 
\int z^{\prime - \alpha} dx^{\prime} \, dy^{\prime} \, dz^\prime 
\\
V &\propto& 
A^{\prime}  z^{\prime 1 - \alpha } 
\\
r^{3/(3-\alpha)} &\propto& r^{\prime}
\end{eqnarray}
therefore, for $\alpha=2$ we have $r^3 \propto r^{\prime}$.  This type
of scaling can be imposed by multiplying each coordinate of the old
positions by $(r/r_0)^2$. 


\subsection{Radial Power Law}

In this case, we write down the expression for the mass in a spherical
shell and derive the scaling that will give us a power law 
$\rho(r_t) \propto r_t^{-\alpha}$.   The new
density is only a function of the magnitude of the new radial
coordinate $r_t$. 

\begin{eqnarray}
4 \pi r^2 \rho({\bf r}) dr =  
4 \pi r_t^{2} \rho(r_t) dr_t
\\  
r^2 \rho_0 dr =
r_t^{2} \rho(r_t) dr_t
\\  
\rho(r_t) =
\rho_0 \left( \frac{r}{r_t} \right)^2 \frac{dr}{dr_t}
\propto r_t^{-\alpha}
\end{eqnarray}
where we have imposed the last proportionality as a requirement for
the new density field. 

\begin{eqnarray}
r^2 dr \propto r^{\prime 2 - \alpha} dr^\prime \\
\int r^2 dr \propto \int r^{\prime 2 - \alpha} dr^\prime \\
r^3 \propto r^{\prime 3 - \alpha} \\
r^{3/(3-\alpha)}  \propto r^{\prime}
\end{eqnarray}
therefore, for $\alpha=2$ we have $r^3 \propto r^{\prime}$.  This type
of scaling can be imposed by multiplying each coordinate of the old
positions by $(r/r_0)^2$. 

\begin{eqnarray}
r'^2 &=& [x (r/r_0)^2]^2 + [y (r/r_0)^2]^2 + [z (r/r_0)^2]^2 \\
&=& x^2 (r/r_0)^4 + y^2 (r/r_0)^4 + z^2 (r/r_0)^4 \\
&=& r^2 (r/r_0)^4 \\
r' &=& r^3 r_0^{-2}
\end{eqnarray}



\bibliographystyle{alpha} % or "unsrt", "alpha", "abbrv", etc.
\bibliography{biblio}	  % use data in file "astrobibl.bib"


\end{document}
